package com.workerhelping.controller;


import com.workerhelping.result.Result;
import com.workerhelping.service.AnalyzeVOService;
import com.workerhelping.vo.AnalyzeRecordMoneyVO;
import com.workerhelping.vo.AnalyzeYearAndMoneyVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/analyze")
public class AnalyzeController {

    @Autowired
    private AnalyzeVOService analyzeVOService;

    /**
     * 每年对应金额
     * @return
     */
    @GetMapping("/getYearAndMoney")
    public Result<List<AnalyzeYearAndMoneyVO>> getYearAndMoney() {
        try {
            List<AnalyzeYearAndMoneyVO> analyzeYearAndMoneyVOS = analyzeVOService.getYearAndMoney();
            return Result.ok(analyzeYearAndMoneyVOS);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail();
        }
    }

    /**
     * 每个档案对应金额
     * @return
     */
    @GetMapping("/getRecordMoney")
    public Result<List<AnalyzeRecordMoneyVO>> getRecordAndMoney() {
        try {
            List<AnalyzeRecordMoneyVO> analyzeRecordMoneyVOS = analyzeVOService.getRecordAndMoney();
            return Result.ok(analyzeRecordMoneyVOS);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail();
        }
    }

}
